/**
 * 
 */
package org.youisoft.summer.evaluator.operator.base;

import org.youisoft.summer.evaluator.operator.AbstractOperator;
import org.youisoft.summer.evaluator.operator.Operator;

/**
 * @author zijiang.jl
 *
 */
public class ListOperator<T extends Operator<?>> extends AbstractOperator<java.util.List<T>>{
	
	public ListOperator(){
		super(new java.util.concurrent.CopyOnWriteArrayList<T>());
	}
	
	public ListOperator(java.util.List<T> list){
		this.setValue(list);
	}
	
	public void addOperator(T operator){
		this.value().add(operator);
	}
	
	
	public T getOperator(int index){
		return this.value().get(index);
	}
	
	
	@SuppressWarnings("unchecked")
	public T getOperator(){
		if(this.value().size()>0) return this.value().get(0);
		return (T)Operator.nullInstance;
	}
	
	public int size(){
		return this.value().size();
		
	}
}
